package flc.ast;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.ImageFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.PlacardFragment;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {


    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        StatusBarUtils.setSystemStatusTextColor(true,this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.llHome));
        listFragment.add(new FragmentViewBinder(PlacardFragment.class,R.id.llPlacard));
        listFragment.add(new FragmentViewBinder(ImageFragment.class,R.id.llImage));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.shouye1);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#FFFF99CF"));
                break;
            case R.id.llPlacard:
                mDataBinding.ivPlacard.setImageResource(R.drawable.haibao1);
                mDataBinding.tvPlacard.setTextColor(Color.parseColor("#FFFF99CF"));
                break;
            case R.id.llImage:
                mDataBinding.ivImage.setImageResource(R.drawable.tupian1);
                mDataBinding.tvImage.setTextColor(Color.parseColor("#FFFF99CF"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.wode1);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#FFFF99CF"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.shouye2);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#4D1F1F1F"));
        mDataBinding.ivPlacard.setImageResource(R.drawable.haibao2);
        mDataBinding.tvPlacard.setTextColor(Color.parseColor("#4D1F1F1F"));
        mDataBinding.ivImage.setImageResource(R.drawable.tupian2);
        mDataBinding.tvImage.setTextColor(Color.parseColor("#4D1F1F1F"));
        mDataBinding.ivMy.setImageResource(R.drawable.wode2);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#4D1F1F1F"));
    }

}